package com.kun.base.redis;

import com.kun.base.model.User;

import javax.servlet.http.HttpSession;

/**
 * Created by admin on 2017/8/11.
 */
public class RedisUtil {

    /**
     * 清除存在缓存中的用户数据
     * @param session
     */
    public static void clearUserInfo(HttpSession session){
        RedisClient redisClient=new RedisClient();
        User user= (User) session.getAttribute("user");
        if (user!=null){
            Integer id = user.getId();
            redisClient.delete("user_permissions_"+id.intValue());
            redisClient.delete("user_roles_"+id.intValue());
        }
    }
}
